package com.analyse.stock.enums;

import org.apache.commons.lang3.StringUtils;

public enum IndexCategoryEnum {
    SZ_INDEX("m:0+t:5","0","SZ","深证系列指数"),
    SH_INDEX("m:1+s:2","1","SH","上证系列指数"),
    MED_INDEX("m:2","2","ZZ","中证系列指数"),
    //INDEX_COMPONENT("m:1+s:3,m:0+t:5","","指数成份")
    ;
    IndexCategoryEnum(String code,String markCode,String shortMarkCode, String desc) {
        this.code = code;
        this.desc = desc;
        this.markCode = markCode;
        this.shortMarkCode = shortMarkCode;
    }

    private final String code;
    private final String markCode;
    private final String shortMarkCode;
    private final String desc;

    public String getCode() {
        return this.code;
    }
    public String getMarkCodee() {
        return this.markCode;
    }
    public String getShortMarkCodee() {
        return this.shortMarkCode;
    }

    public String getName() {
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        if(StringUtils.isBlank(code)) {
            return StringUtils.EMPTY;
        }
        for (IndexCategoryEnum anEnum : values()) {
            if (anEnum.getCode().equalsIgnoreCase(code)){
                return anEnum.getDesc();
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getByName(String name){
        if(StringUtils.isBlank(name)) {
            return StringUtils.EMPTY;
        }
        for (IndexCategoryEnum anEnum : values()) {
            if (anEnum.name().contains(name.toUpperCase())){
                return anEnum.getCode();
            }
        }
        return StringUtils.EMPTY;
    }
}
